import { createRouter, createWebHistory } from 'vue-router'
// 导入组件
import LoginVue from '@/views/Login.vue'
import LayoutVue from '@/views/Layout.vue'
import ArticleCategory from '@/views/article/ArticleCategory.vue'
import ArticleManage from '@/views/article/ArticleManage.vue'
import UserAvatar from '@/views/user/UserAvatar.vue'
import UserInfo from '@/views/user/UserInfo.vue'
import UserResetPassword from '@/views/user/UserResetPassword.vue'


const routes = [
  {
    path: '/login',
    name: 'Login',
    component: LoginVue
  },
  {
    path: '/',
    name: 'layout',
    component: LayoutVue,
    redirect: '/article/category',
    children: [
      {
        path: '/article/category',
        name: 'articleCategory',
        component: ArticleCategory    
      },
      {
        path: '/article/manage',
        name: 'articleManage',
        component: ArticleManage
      },
      {
        path: '/user/avatar',
        name: 'avatar',
        component: UserAvatar
      },
      {
        path: '/user/info',
        name: 'userInfo',
        component: UserInfo
      },
      {
        path: '/user/resetPassword',
        name: 'resetPassword',
        component: UserResetPassword
      }
    ]
  }
]

// 创建路由实例并传递 `routes` 配置
const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),  // 默认建议
  history: createWebHistory(), 
  routes: routes,
})

export default router
